package main

import (
	"log"
	"os"
	"os/signal"
	"syscall"

	"gitee.com/shiwjlinux/shoplink/consumer"
	"gitee.com/shiwjlinux/shoplink/models"
	"gitee.com/shiwjlinux/shoplink/producer"
)

func main() {
	go consumer.ConsumeInventory() // 启动库存消费者
	go consumer.ConsumeOrder()     // 启动订单消费者
	order := models.Order{
		OrderID:   "123",
		ProductID: "p001",
		Quantity:  2,
	}

	err := producer.ProduceOrder(order) // 生产订单
	if err != nil {
		panic(err)
	}

	sigChan := make(chan os.Signal, 1)
	signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)
	<-sigChan
	log.Println("Shutting down...")
}
